package com.qf.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Arrays;
import java.util.Date;

/**
 * @author fy
 * @version V1.0
 * @Project workspace
 * @Package com.qf.pojo
 * @Description:
 * @Date 2022/6/7 17:25
 */
public class User {

    //jaskon的注解：Json转换的时候忽略这个字段
    //@JsonIgnore

    //阿里fastJson忽略属性
    @JSONField(serialize = false)
    private Integer id;
    private String name;

    //性别，json转换的时候给key改名字
    //页面传过来的sex性别会直接填充到gender中
    //jaskon的注解：转换成json格式字符串的话叫做sex不叫gender
    //@JsonProperty("sex")

    //阿里fastJson注解更改属性名
    @JSONField(name = "sex")
    private Boolean gender;


    @DateTimeFormat(pattern = "yyyy-MM-dd")
    //jaskon的注解：json转换时候的日期格式化
    //@JsonFormat(pattern = "yyyy-MM-dd")
    //阿里fastjson注释：json转换时候的日期格式化
    @JSONField(format = "yyyy-MM-dd")
    private Date bornDate;

    //爱好
    //jaskon的注解：如果这个字段值为null，那么不参与json转换，自动忽略掉
   // @JsonInclude(JsonInclude.Include.NON_NULL)

    private String[] hobby;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Date getBornDate() {
        return bornDate;
    }

    public void setBornDate(Date bornDate) {
        this.bornDate = bornDate;
    }

    public String[] getHobby() {
        return hobby;
    }

    public void setHobby(String[] hobby) {
        this.hobby = hobby;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", bornDate=" + bornDate +
                ", hobby=" + Arrays.toString(hobby) +
                '}';
    }
}
